matrix multiplication using functions